﻿package core.ui.controls
{
    import core.enum.*;
    import flash.display.*;
    import flash.events.*;

    public class ToolButton extends Sprite
    {
        private var bg:Sprite;
        private var small:Bitmap;
        private var down:Function;
        private var over:Function;
        private var out:Function;
        public var type:ToolType;
        private var marked:Boolean = false;

        public function ToolButton(param1:ToolType, param2:BitmapData, param3:int, param4:int, param5:Function, param6:Function, param7:Function)
        {
            this.type = param1;
            this.down = param5;
            this.over = param6;
            this.out = param7;
            this.x = param3;
            this.y = param4;
            this.bg = new Sprite();
            this.bg.graphics.beginFill(7961731);
            this.bg.graphics.drawRect(0, 0, 24, 24);
            this.bg.graphics.beginFill(14606822);
            this.bg.graphics.drawRect(1, 1, 22, 22);
            this.bg.graphics.endFill();
            this.bg.alpha = 0;
            addChild(this.bg);
            this.small = new Bitmap(param2);
            this.small.x = 3;
            this.small.y = 3;
            addChild(this.small);
            this.addEventListener(MouseEvent.MOUSE_DOWN, param5, false, 0, true);
            this.addEventListener(MouseEvent.MOUSE_OVER, this.MouseOver, false, 0, true);
            this.addEventListener(MouseEvent.MOUSE_OUT, this.MouseOut, false, 0, true);
            return;
        }// end function

        private function MouseOver(event:MouseEvent) : void
        {
            if (!this.marked)
            {
                this.bg.alpha = 1;
            }
            this.over(event);
            return;
        }// end function

        private function MouseOut(event:MouseEvent) : void
        {
            if (!this.marked)
            {
                this.bg.alpha = 0;
            }
            this.out(event);
            return;
        }// end function

        public function Mark(param1:Boolean)
        {
            this.marked = param1;
            if (param1)
            {
                this.bg.alpha = 1;
            }
            else
            {
                this.MouseOut(null);
            }
            return;
        }// end function

    }
}
